import areaData from '@/assets/js/area.json';
const aData = areaData['country_list'];
const region = aData['ALL']; // 大区
const regionData = [];

// 计算大区
for (const prop in region) {
    regionData.push({
        value: region[prop]['name'], // 省份code值
        label: region[prop]['cn_name'] // 省份汉字
    });
}
// 计算国家
for (let i = 0, len = regionData.length; i < len; i++) {
    const countryCode = regionData[i].value;
    const countryChildren = [];
    for (const prop in aData[countryCode]) {
        countryChildren.push({
            value: aData[countryCode][prop]['iso_code_3'],
            label: aData[countryCode][prop]['cn_name'],
            icon: aData[countryCode][prop]['flag']
        });
    }
    if (countryChildren.length) {
        regionData[i].children = countryChildren;
    }
}

export default regionData;
